<?php
/**
 * 观察者主题抽象
 * @author 王志昂<wangzhiang@myhexin.com>
 * @create 2013-4-19 10:31:43
 */
abstract class Subscribe_Push_Subject_Abstract implements Subscribe_Subject
{
	protected $_observers;
	
	public function __construct()
	{
		$this->_observers = array();
	}
	
	public function registerObserver(Subscribe_Push_Observer $observer)
	{
		$this->_observers[] = $observer;
	}
	
	public function removeObserver(Subscribe_Push_Observer $observer)
	{
		$newObservers = array();
		foreach ($this->_observers as $obs) {
			if ($obs !== $observer) {
				$newObservers[] = $obs;
			}
		}
		$this->_observers = $newObservers;
	}
	
	public function notifyObserver($style, $change)
	{
		foreach ($this->_observers as $obs) {
			$obs->update($style, $change);
		}
	}
	
	abstract public function dealTrigger();
}